#include <stdio.h>
#include <stdlib.h>
#include <csp_spu.h>
#include <csp_debug.h>


int global_var_number;


int fact_cs(int counter) {
	int save_number = global_var_number;

	csp_yield();

	ASSERT( (global_var_number) == counter  );
	ASSERT( (global_var_number + 1) != counter );

	if(global_var_number == 0){
		return 1;
	}
	global_var_number -= 1;
	return save_number * fact_cs(counter - 1);
}


int Run(){
	PRINTF_FOR_TESTING("globalvars_task running.\n");
	
	global_var_number = 5;
	int res120 = fact_cs(5);

	ASSERT(120 == res120);	
	ASSERT(121 != res120);	

	PRINTF_FOR_TESTING("globalvars_task terminated 120=%i.\n", res120);
	return res120+721;
}

